#!/usr/bin/env python


import os
import sys
import shutil

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from runtest_dalton import Filter, TestRun

test = TestRun(__file__, sys.argv)

a = Filter()
a.add(string = 'Final HF energy',
      rel_tolerance = 1.0e-8)
a.add(string = 'CONTRIBUTION TO HYPVAL',
      abs_tolerance = 1.0e-8)
a.add(string = '@ omega B',
      abs_tolerance = 1.0e-8)
test.run(['rsp_g_rohfx_direct_1.dal'], ['CH2_STO3G.mol'], f={'out': a}, args='-get SIRIUS.RST')
shutil.move('rsp_g_rohfx_direct_1_CH2_STO3G.SIRIUS.RST','SIRIUS.RST')

b = Filter()
b.add(string = 'Final HF energy',
      rel_tolerance = 1.0e-8)
b.add(from_string = 'FREQUENCY INDEPENDENT SECOND ORDER PROPERTIES',
      num_lines = 6,
      rel_tolerance = 1.0e-8)
test.run(['rsp_g_rohfx_direct_2.dal'], ['CH2_STO3G.mol'], f={'out': b}, args='-put SIRIUS.RST -get SIRIUS.RST')
shutil.move('rsp_g_rohfx_direct_2_CH2_STO3G.SIRIUS.RST','SIRIUS.RST')

c = Filter()
c.add(string = 'Final HF energy',
      rel_tolerance = 1.0e-8)
c.add(from_string = 'FREQUENCY INDEPENDENT SECOND ORDER PROPERTIES',
      num_lines = 6,
      rel_tolerance = 1.0e-8)
test.run(['rsp_g_rohfx_direct_3.dal'], ['CH2_STO3G.mol'], f={'out': c}, args='-put SIRIUS.RST')
os.remove('SIRIUS.RST')

sys.exit(test.return_code)
